/*
 * \brief  Root server interface
 * \author Norman Feske
 * \date   2006-05-11
 */

/*
 * Copyright (C) 2006-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__ROOT__SERVER_H_
#define _INCLUDE__ROOT__SERVER_H_

#include <base/server.h>
#include <root/root.h>

namespace Genode {

	class Root_server : public Server_object, public Root
	{
		public:

			int dispatch(int op, Ipc_istream &is, Ipc_ostream &os)
			{
				switch (op) {

				case SESSION:
					{
						Buffer args_buf;
						is >> args_buf;
						Session_capability out_session = session(args_buf.addr());
						os << out_session;
						return out_session.valid() ? 0 : -1;
					}

				case CLOSE:
					{
						Session_capability session;
						is >> session;
						close(session);
						return 0;
					}
				}
				return -1;
			}
	};
}

#endif /* _INCLUDE__ROOT__SERVER_H_ */
